module lsm_offset_gen(
  input  [ 4:0] in,
  input         p,
  input         up,
  output [ 4:0] out
);

assign out = p ? (up ? 5'b1 : in) : (up ? 5'b0 : in-5'b1);

endmodule
